<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/mui.picker.min.css"/>
		<link rel="stylesheet" type="text/css" href="css/mui.poppicker.css"/>
		<link rel="stylesheet" type="text/css" href="css/general.css"/>
		
		<style type="text/css">
			*{
				font-size: 0.9em;
			}
			.main{
				width: 100%;
				height: calc(100vh - 44px);
				background-color: white;
				padding: 0.5em;
			}
			.bdiv{
				border: 1px solid #C7C7C7;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				height: 48px;
				border-radius: 10px;
				margin: 1em 0;
			}
			.bdiv>div{
				width: 25%;
				border-right: 1px solid #C7C7C7;
				height: 80%;
				display: flex;
				align-items: center;
				justify-content: center;
			}
			.bdiv>input{
				width: 50%;
				border: 0;
				height: 44px;
				margin-bottom: 0px;
				padding: 10px 15px;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav hbg">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left colorw"></a>
		    <h1 class="mui-title">注册</h1>
		</header>
		<div class="mui-content">
		    <div class="main">
		    	<div class="bdiv">
		    	    <div>手机号码</div>
		    	    <input type="text" id='phone' placeholder="请输入手机号">
		    	</div>
		    	
		    	<div class="bdiv">
		    	    <div>验证码</div>
		    	    <input type="text" id='code' value="" placeholder="请输入验证码" >
		    	    <div id="getcode">
		    	    	获取验证码
		    	    </div>
		    	</div>
		    	<div class="bdiv">
		    	    <div>公司名</div>
		    	    <input type="text" id='name' placeholder="请输入公司名">
		    	</div>
		    	<div class="bdiv">
		    	    <div>行业</div>
		    	    <input type="text" readonly="readonly" id='trade' placeholder="请选择行业">
		    	</div>
		    	<div class="bdiv">
		    	    <div>密码</div>
		    	    <input type="password" id='password'  placeholder="请输入密码">
		    	</div>
		    	<div class="bdiv">
		    	    <div>确认密码</div>
		    	    <input type="password" id='password2' placeholder="请输入确认密码">
		    	</div>
		    	<div class="">
		    		<button type="button" id="reg" class="mui-btn mui-btn-blue mui-btn-block">注册</button>
		    	</div>
		    
		    </div>
		    
		</div>
		<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/mui.min.js"></script>
		<script src="js/mui.picker.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/mui.poppicker.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/req.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/muishow.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/app.js"></script>
		<script type="text/javascript">
			var trade_id = 0;
			(function(mui,doc){
				var settings = app.getSettings();
				var regButton = doc.getElementById('reg');
				var phone = doc.getElementById('phone');
				var name = doc.getElementById('name');
				var address = doc.getElementById('address');
				var code = doc.getElementById('code');
				var pword = doc.getElementById('password');
				var pword2 = doc.getElementById('password2');
				var getcode = doc.getElementById('getcode');
				
				var trade =  doc.getElementById('trade');
				
				var data = {
						url:"/api/trade/lst",
						data:{}
					}
					ajax(data,function(res){
						console.log("行业列表",res)
						var list1 = [];
						for(var i = 0; i < res.data.length; i++){
							var str = {
								value:res.data[i].id,
								text:res.data[i].trade_name
							}
							list1.push(str);
						}
						var levelPicker = new mui.PopPicker();
		                levelPicker.setData(list1);
		                trade.addEventListener('tap', function(event) {
		                    levelPicker.show(function(items) {
		                        trade.value = items[0].text;
		                        trade_id = items[0].value;
		                    });
		                }, false);
					},"get")
				
				
				
				regButton.addEventListener('tap', function(event) {
					if(pword.value!= pword2.value){
						mui.toast("请两次密码不一致，请重新输入");
						return;
					}
						var regInfo = {
							url:"/api/company/reg",
							data:{
								phone: phone.value,
								code: code.value,
								name: name.value,
								trade_id:trade_id,
								password: pword.value
							}
						};
						ajax(regInfo,function(res){
							mui.toast(res.msg);
							setTimeout(function(e){
								mui.back();
							},1000)
							
						})
						/*app.reg(regInfo, function(err) {
							if (err) {
								plus.nativeUI.toast(err);
								return;
							}
							mui.toast('注册成功');
							mui.openWindow({
								url: 'login.html',
								id: 'login',
								show: {
									aniShow: 'pop-in'
								}
							});
						});*/
					});
					//http://spai.chentaohua.com/api/code/get?phone=13638642400 
				getcode.addEventListener('tap', function(event) {
						var data = {
							url:"/api/code/get",
							data:{
								phone:phone.value,
								exist:1
							}
						}
						ajax(data,function(res){
							if(res.error_code == 0){
								mui.toast(res.msg);
							}
						})
						
					});	
				
				
			})(mui,document)
		</script>
	</body>

</html>